package com.googlecode.spreadit.activity;

import android.app.Activity;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;

import com.googlecode.spreadit.R;

/**
 * This {@link Activity} relates to the {@link R.layout#about "About" screen}.
 * 
 * @author Markus L. Dechert (markus.dechert@googlemail.com)
 */
public class About extends Activity {

	private final String LOG_TAG = getClass().getSimpleName();

	public static final String HANDLER_ID = "com.googlecode.spreadit.activity.ABOUT";

	/**
	 * Called when the activity is first created. Initializes dynamic
	 * information (like version number) and registers {@link OnClickListener}s.
	 */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.about);

		PackageInfo pinfo;
		try {
			pinfo = this.getPackageManager()
					.getPackageInfo(getPackageName(), 0);
			TextView t = (TextView) findViewById(R.id.about_VersionNumber);
			t.setText(pinfo.versionName);
		} catch (NameNotFoundException e) {
			Log.v(LOG_TAG, e.getMessage());
		}

		Button backButton = (Button) findViewById(R.id.about_BackButton);
		backButton.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				finish();
			}

		});
	}
}